<?php
/* @var $this UsersController */
/* @var $model Users */
/* @var $form CActiveForm */
?>

<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'users-form',
	// Please note: When you enable ajax validation, make sure the corresponding
	// controller action is handling ajax validation correctly.
	// There is a call to performAjaxValidation() commented in generated controller code.
	// See class documentation of CActiveForm for details on this.
	'enableAjaxValidation'=>false,
)); ?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary($model); ?>
    <div class="row">
        <div class="span6">
            <?php echo $form->labelEx($model,'gh_id'); ?>
            <?php $list = CHtml::listData(Gh::model()->findAll(), 'id', 'name');
            echo $form->dropDownList($model,'gh_id',$list, array('empty' => 'Select a gh', 'options' => array($model->gh_id=>array('selected'=>true))));
            ?>
            <?php echo $form->error($model,'gh_id'); ?>
        </div>
        <div class="span6 list-gx">
            <?php echo $form->labelEx($model,'gx_id'); ?>
            <!--<?php echo $form->textField($model,'gx_id'); ?>-->
            <?php $list = CHtml::listData(Gx::model()->findAll(), 'id', 'name');
            echo $form->dropDownList($model,'gx_id',$list, array('empty' => 'Select a gx', 'options' => array($model->gx_id=>array('selected'=>true))));
            ?>
            <?php echo $form->error($model,'gx_id'); ?>
        </div>
    </div>

    <div class="row">
        <div class="span3">
            <div class="">
                <?php echo $form->labelEx($model,'username'); ?>
                <?php echo $form->textField($model,'username',array('size'=>60,'maxlength'=>255)); ?>
                <?php echo $form->error($model,'username'); ?>
            </div>

            <div class="">
                <?php echo $form->labelEx($model,'password'); ?>
                <?php echo $form->passwordField($model,'password',array('size'=>60,'maxlength'=>255, 'value'=>'')); ?>
                <?php echo $form->error($model,'password'); ?>
            </div>

            <div class="">
                <?php echo $form->labelEx($model,'firstname'); ?>
                <?php echo $form->textField($model,'firstname',array('size'=>60,'maxlength'=>255)); ?>
                <?php echo $form->error($model,'firstname'); ?>
            </div>

            <div class="">
                <?php echo $form->labelEx($model,'lastname'); ?>
                <?php echo $form->textField($model,'lastname',array('size'=>60,'maxlength'=>255)); ?>
                <?php echo $form->error($model,'lastname'); ?>
            </div>

            <div class="">
                <?php echo $form->labelEx($model,'phone'); ?>
                <?php echo $form->textField($model,'phone',array('size'=>11,'maxlength'=>11)); ?>
                <?php echo $form->error($model,'phone'); ?>
            </div>

            <div class="">
                <?php echo $form->labelEx($model,'email'); ?>
                <?php echo $form->textField($model,'email',array('size'=>60,'maxlength'=>255)); ?>
                <?php echo $form->error($model,'email'); ?>
            </div>

            <div class="">
                <?php echo $form->labelEx($model,'address'); ?>
                <?php echo $form->textField($model,'address',array('size'=>60,'maxlength'=>255)); ?>
                <?php echo $form->error($model,'address'); ?>
            </div>

            <div class="">
                <?php echo $form->labelEx($model,'photo'); ?>
                <?php echo $form->textField($model,'photo',array('size'=>60,'maxlength'=>255)); ?>
                <?php echo $form->error($model,'photo'); ?>
            </div>
        </div>


        <div class="span6">
            <div class="widget widget-nopad">
                <div class="widget-header"> <i class="icon-list-alt"></i>
                    <h3> Level</h3>
                </div>
                <!-- /widget-header -->
                <div class="widget-content">
                    <div class="widget big-stats-container">
                        <div class="widget-content">
                            <div class="control-group">
                                <div class="controls fields-level">
                                    <?php
                                    $list = CHtml::listData(Level::model()->findAll(), 'id', 'name');
                                    if(!empty($model->userLevels)) {
                                        foreach($model->userLevels as $level) { ?>
                                            <div class="col-md-12 text-center level">
                                                <input type="hidden" name="UserLevel[id][]" value="<?php echo $level->id?>">
                                                <input type="text" name="UserLevel[year][]" class="span2" value="<?php echo $level->year?>" placeholder="year">
                                                <?php
                                                echo CHtml::dropDownList('UserLevel[level_id][]','name', $list, array('empty' => 'Select a level', 'options' => array($level->level_id=>array('selected'=>true))));
                                                ?>
                                                <button rel="<?php echo Yii::app()->createUrl('admin/userlevel/delete', array('id'=>$level->id)). "?ajax=user-level-grid"?>" class="btn btn-default btn-danger btn-remove">-</button>
                                            </div>
                                            <?php
                                        }
                                    }?>
                                    <div class="level-add">
                                        <input type="hidden" name="UserLevel[id][]" value="">
                                        <input type="text" name="UserLevel[year][]" class="span2" value="" placeholder="year">
                                        <?php
                                            echo CHtml::dropDownList('UserLevel[level_id][]','name', $list, array('empty' => 'Select a level'));
                                        ?>
                                    </div>
                                </div> <!-- /controls -->
                                <div class="controls">
                                    <button rel="level" class="btn btn-default btn-add">+</button>
                                </div> <!-- /controls -->
                            </div>

                        </div>
                        <!-- /widget-content -->
                    </div>
                </div>
            </div>
            <div class="widget widget-nopad">
                <div class="widget-header"> <i class="icon-list-alt"></i>
                    <h3> SM TL</h3>
                </div>
                <!-- /widget-header -->
                <div class="widget-content">
                    <div class="widget big-stats-container">
                        <div class="widget-content">
                            <div class="control-group">
                                <div class="controls fields-training1">
                                    <?php
                                    if(!empty($model->trainings_1)) {
                                        foreach($model->trainings_1 as $training) {?>
                                            <div class="col-md-12 text-center training1">
                                                <input type="hidden" name="TrainingTL[id][]" value="<?php echo $training->id?>">
                                                <input type="text" name="TrainingTL[year][]" class="span2" value="<?php echo $training->year;?>" placeholder="year">
                                                <input type="text" name="TrainingTL[point_1][]" class="span2" value="<?php echo $training->point_1;?>" placeholder="Point 1">
                                                <input type="text" name="TrainingTL[point_2][]" class="span2" value="<?php echo $training->point_2;?>" placeholder="Point 2">
                                                <button rel="<?php echo Yii::app()->createUrl('admin/training/delete', array('id'=>$training->id)). "?ajax=training-grid"?>" class="btn btn-default btn-danger btn-remove">-</button>
                                            </div>
                                        <?php }
                                    }
                                    ?>
                                    <div class="col-md-12 text-center training1-add">
                                        <input type="hidden" name="TrainingTL[id][]" value="">
                                        <input type="text" name="TrainingTL[year][]" class="span2" value="" placeholder="year">
                                        <input type="text" name="TrainingTL[point_1][]" class="span2" value="" placeholder="Point 1">
                                        <input type="text" name="TrainingTL[point_2][]" class="span2" value="" placeholder="Point 2">
                                    </div>
                                </div> <!-- /controls -->
                                <div class="controls">
                                    <button rel="training1" class="btn btn-default btn-add">+</button>
                                </div> <!-- /controls -->
                            </div>
                        </div>
                        <!-- /widget-content -->
                    </div>
                </div>
            </div>
            <!-- /widget -->
            <div class="widget widget-nopad">
                <div class="widget-header"> <i class="icon-list-alt"></i>
                    <h3> SM KN</h3>
                </div>
                <!-- /widget-header -->
                <div class="widget-content">
                    <div class="widget big-stats-container">
                        <div class="widget-content">
                            <div class="control-group">
                                <div class="controls fields-training2">
                                    <?php
                                    if(!empty($model->trainings_2)) {
                                        foreach($model->trainings_2 as $training) {?>
                                            <div class="col-md-12 text-center training2">
                                                <input type="hidden" name="TrainingKN[id][]" value="<?php echo $training->id?>">
                                                <input type="text" name="TrainingKN[year][]" class="span2" value="<?php echo $training->year?>" placeholder="year">
                                                <input type="radio" name="TrainingKN[result][]" value="<?php echo Training::PASS;?>" <?php if($training->result == 1) echo 'checked="checked"';?>> Pass
                                                <input type="radio" name="TrainingKN[result][]" value="<?php echo Training::FAIL;?>" <?php if($training->result == 2) echo 'checked="checked"';?>> Fail
                                                <button rel="<?php echo Yii::app()->createUrl('admin/training/delete', array('id'=>$training->id)). "?ajax=training-grid"?>" class="btn btn-default btn-danger btn-remove">-</button>
                                            </div>
                                        <?php }
                                    }?>

                                    <div class="col-md-12 text-center training2-add">
                                        <input type="hidden" name="TrainingKN[id][]" value="">
                                        <input type="text" name="TrainingKN[year][]" class="span2" value="" placeholder="year">
                                        <input type="radio" name="TrainingKN[result][]" value="<?php echo Training::PASS;?>"> Pass
                                        <input type="radio" name="TrainingKN[result][]" value="<?php echo Training::FAIL;?>"> Fail
                                    </div>
                                </div> <!-- /controls -->
                                <div class="controls">
                                    <button rel="training2" class="btn btn-default btn-add">+</button>
                                </div> <!-- /controls -->
                            </div>
                        </div>
                        <!-- /widget-content -->

                    </div>
                </div>
            </div>
            <!-- /widget -->
        </div>
    </div>

	<div class=" buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
	</div>
<?php $this->endWidget(); ?>

</div><!-- form -->